import React from "react";
import { NavLink, useNavigate, To, NavigateOptions, Navigate } from "react-router-dom";
const Index = () => {
  const navigate = useNavigate();

  return (
    <div>
      我的页面
      <NavLink to="/class">去类页面</NavLink>
      <button onClick={() => navigate("/class")}>去类页面</button>
      <button
        onClick={() =>
          navigate(
            {
              pathname: "/login/1231231231231/张三",
              search: "pageCode=1&pageSize=10",
              hash: "qweqwnqweqw",
            },
            {
              state: [1, 2, 3, 4, 5],
            }
          )
        }
      >
        去登录页面
      </button>
    </div>
  );
};


const withLogin = (Comp: any) => {
	return () => {
		const token = localStorage.getItem('token')
		if(token) {
			return <Comp></Comp>
		}

		return <Navigate to="/login/12312/1231231"></Navigate>
	}
}

export default withLogin(Index);
